﻿#I @"C:\Users\Johan\Desktop\WingBeats\bin\Debug"
#I @"C:\Users\joel.mueller\Documents\Visual Studio 2010\Projects\WingBeats\bin\Debug"
#r "WingBeats"
#r "WingBeats.Xhtml"
#load "patterns.fsx"

  //////////////////////////////////////////
 // This script page is a testing ground //
//////////////////////////////////////////

open WingBeats.Xhtml
open WingBeats.Xml
open Patterns

let e = XhtmlElement() // let e, a = DocType(Xhtml1Strict)
let p = Patterns.Patterns()

let myTemplate title menuLinks =
    { defaultPage with
        Title         = title 
        HeadContent   = fun c -> [ p.StyleSheet "/styles/main.css" 
                                   p.JavaScriptFile "/scripts/main.js" ]
        HeaderContent = fun c -> [ e.H1 "#logo" [ e.Str "Company" ]
                                   menu (menuLinks
                                         |> Seq.map (fun l -> let name, url, selected = l
                                                              { defaultLink with
                                                                  Name     = name
                                                                  Url      = url
                                                                  Selected = selected  
                                                              })
                                        )
                                 ]
        MainContent   = fun c -> [ e.H1 [ e.Str c.Title ]
                                   Node.Placeholder ("main-content")
                                 ]
    }
        
let pa str  = e.P [ e.Str str ]
let content = fun () -> e.Div [ pa "my little paragraph"
                                pa "and another paragraph" ]

let output = (myTemplate "Johans sida" Seq.empty).ToNode()
             |> WingBeats.Xml.Render.renderTemplateToString
                    ([ ("main-content", content) ]
                     |> Map.ofList)